<?php
	require_once("conexion/conexion.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Formulario</title>
<link href="Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />

<script src="include_js/jquery.js" type="text/javascript"></script>
<script src="include_js/funciones.js" type="text/javascript"></script>


<style>
.texto
{
	font-size:14px;
	margin-left:10px;
	font:Verdana, Arial, Helvetica, sans-serif; 
	color:#0066CC;
}
.borde
{
	/*border:0px solid #6593C0;*/
	border:1px solid #D3E4E5;
}
.asterisco
{
	color:#0000FF;
	font-weight:bold;
}
.radioBorde
{ 
 background:#D3E4E5;
 border:0px solid #89C0C7;
}
</style>
<script>
function ActivaMenu()
{
	$.ajax({
            type: 'POST',
            url: 'Contabilidad/MenuCajaChica.php',
            data: $('#form_Honorario').serialize(),
            success: function(data) {
                $('#mensaje').html(data);
            }
        })
}

function BorraDatos(dato)
{
	var cadena = dato.substring(8,9);
    if(cadena=='1')
	{
		 $.ajax({
            type: 'POST',
            url: 'Contabilidad/MenuCajaChica.php',
            data: $('#form_Honorario').serialize(),
            success: function(data) {
                $('#mensaje').html(data);
            }
        })
	}
}

function AbrirCaja()
{ 
        $.ajax({
            type: 'POST',
            url: 'Contabilidad/Ingresa_CajaChica.php',
            data: $('#form_Honorario').serialize(),
            success: function(data) {
                $('#mensaje').html(data);
				BorraDatos(data);
            }
        })
}
</script>
</head>
<body>
<form name="form_Honorario" id="form_Honorario" method="post">
<div class='option2'><label style="font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;">Secci&oacute;n Caja Chica.</label></div>
<div id="capa">
<?php
	$con = new Conexion();
    $con2 = $con->conexionBD("fpproduccion");
	$sql1 = "select max(CajId) from caja";
	$res = mysql_query($sql1) or die ($con->error_mysql("Error en la consulta".mysql_error()));
	$cajaId = mysql_fetch_array($res);
	//echo 'idcaja'.$cajaId[0];
	$sql = "select CajEstado from caja where CajId='".$cajaId[0]."'";
    $resultado = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
	$estado = mysql_fetch_array($resultado);
	$con->cerrarBD();
	//echo 'estado'.$estado[0];
	if($estado[0]!="ACTIVO")
	{
?>
<div class='groupbox'>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="uno">
<tr>
  <td class="borde" colspan="2"><div style="float:left; clear:none; margin-left:10px; margin-top:5px;"><label style="color:#0000FF; font-size:12px; font-weight:bold;">Datos Obligatorios(*)</label></div></td>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde" colspan="4"><hr /></td>
</tr>
<tr>
  <td class="borde" colspan="2"><label class="texto" style="font-weight:bold;">Abrir Caja.</label></td>
  <td width="7%" class="borde">&nbsp;</td>
  <?php 
  	$con = new Conexion();
    $con2 = $con->conexionBD("fpproduccion");
	$sql = "select CajMontoAct from caja where CajId='".$cajaId[0]."'";
    $resultado = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
	$montoAct = mysql_fetch_array($resultado);
	$con->cerrarBD();
  ?>
  <td width="35%" class="borde"><label class="texto">Monto Actual: <?php echo "$".number_format ($montoAct[0],0,',','.');?></label></td>
  </tr>
<tr>
  <td width="22%" class="borde">&nbsp;</td>
  <td width="36%" class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
  <td class="borde"><input type="hidden" name="txtMontoActual" id="txtMontoActual" value="<?php echo $montoAct[0];?>" /></td>
</tr>
<tr>
    <td class="borde"><label class="texto" style="margin-left:35px;">Fecha:</label></td>
	  <td class="borde" colspan="3"><input name="txtFecha" type="text" id="txtFecha" size="10">&nbsp;<img src="imagen/img.gif" width="20" height="14" title="calendario" style="cursor: pointer; border: 1px solid green;" onmouseover="this.style.background='black';" onmouseout="this.style.background=''" onclick="popUpCalendar(txtFecha, form_Honorario.txtFecha, 'dd-mm-yyyy');" />&nbsp;<label class="asterisco">*</label></td></tr>
<tr>
  <td class="borde"><label class="texto" style="margin-left:35px;">Monto ($):</label></td>
  <td class="borde"><input type="text" name="txtMontoCaja" id="txtMontoCaja" onkeyup="puntitos(this,this.value.charAt(this.value.length-1))"/>&nbsp;<label class="asterisco">*</label></td>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde"><label class="texto" style="margin-left:35px;">Observaci&oacute;n:</label></td>
  <td class="borde" colspan="3"><textarea name="txtObsCaja" id="txtObsCaja" cols="60" rows="3"></textarea></td>
</tr>
  
  <tr>
    <td class="borde" colspan="4">&nbsp;</td>
  </tr> 
  <tr>
    <td class="borde" colspan="4"><div class="formtail"><input name="btn_Abrir_Caja" id="btn_Abrir_Caja" type="button" value="Abrir Caja" onclick="AbrirCaja();" /></div></td>
  </tr>
</table>

</div>
<?php }
if($estado[0]=="ACTIVO")
{
	echo "<script>ActivaMenu();</script>";
}
?>
</div>

</form>
<div id="mensaje"></div>
</body>
</html>